
import Ref from "../ref/Ref.js";
import { locationPath } from "./RenteLocation.js";

export default class RenteRoute {

  /** @type { RenteRouteConfig[] } */
  config;

  /** @type { RenderConfig } */
  view;

  /** @param { RenteRouteConfig[] } config */
  constructor(config) {
    this.config = config;

    this.view = Ref.calc((path) => {
      const findClass = this.config.find(info => info.path === path);
      return findClass ? new findClass.render() : "";
    }, locationPath);

  }

}
